package com.company;

import java.io.Serializable;

/**
 * Created by v on 16-12-20.
 */
public class StudentTable implements Serializable{
    private MyLinkList<Student> list=new MyLinkList<>();
    private String tableName;

    public StudentTable(String tableName){
        this.tableName=tableName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Student getStudent(String studentNumber){
        for(int i=0;i<list.size();i++){
            if(list.get(i).getStudentNumber().equals(studentNumber)){
                return list.get(i);
            }
        }

        return null;
    }

    //插入学生信息
    public void insertStudent(Student student){
        list.add(student);
    }

    //删除学生信息
    public boolean removeStudent(String studentNumber){
        for(int i=0;i<list.size();i++){
            if(studentNumber.equals(list.get(i).getStudentNumber())){
                return list.remove(i);
            }
        }

        return false;
    }

    @Override
    public String toString() {
        return tableName;
    }

    public MyLinkList<Student> getList() {
        return list;
    }
}
